1import fs from 'node:fs';
2import path from 'node:path';
3
4const ROOT = process.cwd();
5const FIXTURES_DIR = path.join(ROOT, 'tests', 'fixtures');
6
7function walk(dir: string): string[] {
8 const out: string[] = [];
9 for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
10 const fullPath = path.join(dir, entry.name);
11 if (entry.isDirectory()) out.push(...walk(fullPath));
12 else if (entry.name.endsWith('.css')) out.push(fullPath);
13 }
14 return out;
15}
16
17export function getStaticPaths() {
18 return walk(FIXTURES_DIR).map((filePath) => ({
19 params: {
20 path: path.relative(FIXTURES_DIR, filePath).replace(/\.css$/, '').split(path.sep).join('/'),
21 },
22 props: {
23 filePath,
24 },
25 }));
26}
27
28export function GET({ props }: { props: { filePath: string } }) {
29 return new Response(fs.readFileSync(props.filePath, 'utf-8'), {
30 headers: {
31 'Content-Type': 'text/css; charset=utf-8',
32 'Cache-Control': 'no-store',
33 },
34 });
35}